package controller;

import bean.Student;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class XMLController {

    public static void main(String[] args) {
        //1.通过 配置文件生成应用程序上下文(spring的容器)，用来管理类的对象
//        ClassPathXmlApplicationContext context =
//                new ClassPathXmlApplicationContext("springApplicationConfig.xml");
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("serviceDao.xml");

        Student stu = (Student)context.getBean("stu");

        System.out.println(stu.getAge());

        context.close();

        //2.通过spring容器 获取 xml文件中创建的Person类的实例化对象
//        Person person = (Person) context.getBean("person1");
//
//        System.out.println(person);
//
//        PersonService ps = (PersonService) context.getBean("personService2");
//        ps.register(person);


//        Person person2 = (Person) context.getBean("person2");
//        Person person3 = context.getBean(Person.class);
//        Person person4 = context.getBean("person1",Person.class);

//        System.out.println(person1);
//        System.out.println(person2);
//        System.out.println(person4);

//        System.out.println(context.containsBean("person1"));
//        System.out.println(context.containsBean("person4"));

//        System.out.println(context.isSingleton("person1"));
//        System.out.println(context.isPrototype("person1"));
//
//        Person person1 = (Person) context.getBean("person1");
//        Person person2 = (Person) context.getBean("person1");
//        person1.setName("张添齐");
//        System.out.println(person2.getName());

//        String[] p1Alias = context.getAliases("ppp1");
//
//        System.out.println(Arrays.toString(p1Alias));






    }

}
